@ GNU AS assembler header file for ADFS
@ Written by DefMod (Dec  9 2012) on Sun Dec  9 15:49:35 2012
@ Jonathan Coxhead, jonathan@doves.demon.co.uk, 21 Aug 1995

@ OSLib---efficient, type-safe, transparent, extensible,
@ register-safe API coverage of RISC OS
@ 
@ Copyright (c) 1994-2012 Jonathan Coxhead and OSLib maintainers
@ 
@ Licence:
@ 
@    OSLib is free software; you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation; either version 1, or (at your option)
@ any later version - and this with the following clarification and
@ special exception:
@ 
@    Linking this library statically or dynamically with other modules
@ is making a combined work based on this library. Thus, the terms
@ and conditions of the GNU General Public License cover the whole
@ combination.
@ 
@    As a special exception, the copyright holders of this library
@ give you permission to link this library with independent modules
@ to produce an executable, regardless of the license terms of these
@ independent modules, and to copy and distribute the resulting
@ executable under terms of your choice, provided that you also meet,
@ for each linked independent module, the terms and conditions of the
@ license of that module. An independent module is a module which is
@ not derived from or based on this library. If you modify this
@ library, you may extend this exception to your version of the library,
@ but you are not obliged to do so. If you do not wish to do so, delete
@ this exception statement from your version.
@ 
@    OSLib is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@ GNU General Public License for more details.
@ 
@    You should have received a copy of the GNU General Public License
@ along with this programme; if not, write to the Free Software
@ Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, USA.

#ifndef ADFS_Hdr
#  define ADFS_Hdr

#  ifndef Get_Types
#    define Get_Types
#    include "oslib/Types.Hdr"
#  endif

#  ifndef Get_OS
#    define Get_OS
#    include "oslib/OS.Hdr"
#  endif

#  ifndef Get_FileCore
#    define Get_FileCore
#    include "oslib/FileCore.Hdr"
#  endif

@Symbols for constants
#  define Error_ADFSDriverInUse 0x108a0
#  define ADFS_ControllerDiscNotPresent 0x0
#  define ADFS_Controller1772 0x1
#  define ADFS_Controller71X 0x2
#  define ADFS_ControllerST506 0x3
#  define ADFS_ControllerIDE 0x4

@Symbols for structure offsets and sizes
        .struct 0
        .skip   Int
ADFS_Controller                : 


@Symbols for SWI's and SWI reason codes
.set XADFS_DiscOp,0x60240
.set ADFS_DiscOp,0x40240

#  define ADFSDiscOp_Verify 0x0
   @Entry
   @  R1 = &0 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress)
   @  R4 = unverified (Int)

#  define ADFSDiscOp_ReadSectors 0x1
   @Entry
   @  R1 = &1 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 = data (pointer to data)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress)
   @  R3 = next_data (pointer to data)
   @  R4 = unread (Int)

#  define ADFSDiscOp_WriteSectors 0x2
   @Entry
   @  R1 = &2 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 -> data (data)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress)
   @  R3 -> next_data (data)
   @  R4 = unwritten (Int)

#  define ADFSDiscOp_ReadTrack 0x3
   @Entry
   @  R1 = &3 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 = data (pointer to data)

#  define ADFSDiscOp_ReadId 0x3
   @Entry
   @  R1 = &3 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 = data (pointer to data)

#  define ADFSDiscOp_WriteTrack 0x4
   @Entry
   @  R1 = &4 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 -> data (data)

#  define ADFSDiscOp_FormatTrack 0x4
   @Entry
   @  R1 = &4 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 = &0
   @  R4 -> format (FileCore_TrackFormat)

#  define ADFSDiscOp_Seek 0x5
   @Entry
   @  R1 = &5 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)

#  define ADFSDiscOp_Restore 0x6
   @Entry
   @  R1 = &6 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)

#  define ADFSDiscOp_StepIn 0x7
   @Entry
   @  R1 = &7 :OR: flags (Bits)

#  define ADFSDiscOp_StepOut 0x8
   @Entry
   @  R1 = &8 :OR: flags (Bits)

#  define ADFSDiscOp_ReadSectorsViaCache 0x9
   @Entry
   @  R1 = &9 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 = data (pointer to data)
   @  R4 = size (Int)
   @  R6 = cache_handle (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress)
   @  R3 = next_data (pointer to data)
   @  R4 = unread (Int)
   @  R6 = cache_handle_out (Int)

#  define ADFSDiscOp_Specify 0xf
   @Entry
   @  R1 = &F :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress)

.set XADFS_HDC,0x60241
.set ADFS_HDC,0x40241
   @Entry
   @  R2 = controller (pointer to data)
   @  R3 = poll_location (pointer to Int)
   @  R4 = poll_bits (Bits)
   @  R5 = enable_location (pointer to data)
   @  R6 = enable_bits (Bits)

.set XADFS_Drives,0x60242
.set ADFS_Drives,0x40242
   @Exit
   @  R0 = default_drive (Int)
   @  R1 = floppy_count (Int)
   @  R2 = hard_disc_count (Int)

.set XADFS_FreeSpace,0x60243
.set ADFS_FreeSpace,0x40243
   @Entry
   @  R0 -> disc_name (String)
   @Exit
   @  R0 = free (Int)
   @  R1 = max (Int)

.set XADFS_Retries,0x60244
.set ADFS_Retries,0x40244
   @Entry
   @  R0 = mask (Bits)
   @  R1 = value (Bits)
   @Exit
   @  R1 corrupted
   @  R2 = old_value (Bits)
   @  R3 = new_value (Bits)

.set XADFS_DescribeDisc,0x60245
.set ADFS_DescribeDisc,0x40245
   @Entry
   @  R0 -> disc_name (String)
   @  R1 = disc (pointer to FileCore_Disc)

.set XADFS_VetFormat,0x60246
.set ADFS_VetFormat,0x40246
   @Entry
   @  R0 = format (pointer to FileCore_Format)
   @  R1 = drive_no (Int)

.set XADFS_FlpProcessDCB,0x60247
.set ADFS_FlpProcessDCB,0x40247

.set XADFS_ControllerType,0x60248
.set ADFS_ControllerType,0x40248
   @Entry
   @  R0 = drive_no (Int)
   @Exit
   @  R0 = controller (ADFS_Controller)

.set XADFS_PowerControl,0x60249
.set ADFS_PowerControl,0x40249

#  define ADFSPowerControl_ReadSpin 0x0
   @Entry
   @  R0 = &0
   @  R1 = drive_no (Int)
   @Exit
   @  R2 = spinning (Bool)

#  define ADFSPowerControl_SetAutospindown 0x1
   @Entry
   @  R0 = &1
   @  R1 = drive_no (Int)
   @  R2 = spindown_time (Int)
   @Exit
   @  R3 = old_spindown_time (Int)

#  define ADFSPowerControl_SetSpin 0x2
   @Entry
   @  R0 = &2
   @  R1 = drive_no (Int)
   @  R2 = spinning (Bool)

.set XADFS_SetIDEController,0x6024a
.set ADFS_SetIDEController,0x4024a
   @Entry
   @  R2 = controller (pointer to data)
   @  R3 = status_location (pointer to Int)
   @  R4 = status_bits (Bits)
   @  R5 = irq_location (pointer to Int)
   @  R6 = irq_bits (Bits)
   @  R7 = read_code (pointer to code)
   @  R8 = write_code (pointer to code)

.set XADFS_IDEUserOp,0x6024b
.set ADFS_IDEUserOp,0x4024b
   @Entry
   @  R0 = op (Bits)
   @  R2 -> commands (data)
   @  R3 = buffer (pointer to data)
   @  R4 = size (Int)
   @  R5 = timeout (Int)
   @Exit
   @  R0 = status (Int)
   @  R4 = untransferred (Int)
   @  R5 corrupted

.set XADFS_MiscOp,0x6024c
.set ADFS_MiscOp,0x4024c

#  define ADFSMiscOp_Mount 0x0
   @Entry
   @  R0 = &0
   @  R1 = drive_no (Int)
   @  R2 = disc_addr (FileCore_DiscAddress)
   @  R3 = buffer (pointer to data)
   @  R4 = size (Int)
   @  R5 = disc (pointer to FileCore_Disc)

#  define ADFSMiscOp_PollChanged 0x1
   @Entry
   @  R0 = &1
   @  R1 = drive_no (Int)
   @  R2 = sequence_no (Int)
   @Exit
   @  R2 = sequence_no_out (Int)
   @  R3 = result (Bits)

#  define ADFSMiscOp_LockDrive 0x2
   @Entry
   @  R0 = &2
   @  R1 = drive_no (Int)

#  define ADFSMiscOp_UnlockDrive 0x3
   @Entry
   @  R0 = &3
   @  R1 = drive_no (Int)

#  define ADFSMiscOp_PollPeriod 0x4
   @Entry
   @  R0 = &4
   @  R1 -> disc_name (String)
   @Exit
   @  R5 = poll_period (Int)
   @  R6 -> media_type (String)

#  define ADFSMiscOp_EjectDisc 0x5
   @Entry
   @  R0 = &5
   @  R1 = drive_no (Int)

#  define ADFSMiscOp_ReadInfo 0x6
   @Entry
   @  R0 = &6
   @Exit
   @  R0 -> info (FileCore_Info)

.set XADFS_SectorDiscOp,0x6024d
.set ADFS_SectorDiscOp,0x4024d

#  define ADFSSectorDiscOp_Verify 0x0
   @Entry
   @  R1 = &0 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_SectorDiscAddress)
   @  R4 = unverified (Int)

#  define ADFSSectorDiscOp_ReadSectors 0x1
   @Entry
   @  R1 = &1 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R3 = data (pointer to data)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_SectorDiscAddress)
   @  R3 = next_data (pointer to data)
   @  R4 = unread (Int)

#  define ADFSSectorDiscOp_WriteSectors 0x2
   @Entry
   @  R1 = &2 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R3 -> data (data)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_SectorDiscAddress)
   @  R3 -> next_data (data)
   @  R4 = unwritten (Int)

#  define ADFSSectorDiscOp_ReadTrack 0x3
   @Entry
   @  R1 = &3 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R3 = data (pointer to data)

#  define ADFSSectorDiscOp_ReadId 0x3
   @Entry
   @  R1 = &3 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R3 = data (pointer to data)

#  define ADFSSectorDiscOp_WriteTrack 0x4
   @Entry
   @  R1 = &4 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R3 -> data (data)

#  define ADFSSectorDiscOp_FormatTrack 0x4
   @Entry
   @  R1 = &4 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R3 = &0
   @  R4 -> format (FileCore_TrackFormat)

#  define ADFSSectorDiscOp_Seek 0x5
   @Entry
   @  R1 = &5 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)

#  define ADFSSectorDiscOp_Restore 0x6
   @Entry
   @  R1 = &6 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)

#  define ADFSSectorDiscOp_StepIn 0x7
   @Entry
   @  R1 = &7 :OR: flags (Bits)

#  define ADFSSectorDiscOp_StepOut 0x8
   @Entry
   @  R1 = &8 :OR: flags (Bits)

#  define ADFSSectorDiscOp_ReadSectorsViaCache 0x9
   @Entry
   @  R1 = &9 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)
   @  R3 = data (pointer to data)
   @  R4 = size (Int)
   @  R6 = cache_handle (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_SectorDiscAddress)
   @  R3 = next_data (pointer to data)
   @  R4 = unread (Int)
   @  R6 = cache_handle_out (Int)

#  define ADFSSectorDiscOp_Specify 0xf
   @Entry
   @  R1 = &F :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_SectorDiscAddress)

.set XADFS_ECCSAndRetries,0x60250
.set ADFS_ECCSAndRetries,0x40250

.set XADFS_LockIDE,0x60251
.set ADFS_LockIDE,0x40251
   @Entry
   @  R0 = lock (Bool)

.set XADFS_FreeSpace64,0x60252
.set ADFS_FreeSpace64,0x40252
   @Entry
   @  R0 -> disc_name (String)
   @Exit
   @  R0 = free_lo (Bits)
   @  R1 = free_hi (Int)
   @  R2 = max (Int)

.set XADFS_IDEDeviceInfo,0x60253
.set ADFS_IDEDeviceInfo,0x40253

.set XADFS_DiscOp64,0x60254
.set ADFS_DiscOp64,0x40254

#  define ADFSDiscOp64_Verify 0x0
   @Entry
   @  R1 = &0 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress64)
   @  R4 = unverified (Int)

#  define ADFSDiscOp64_ReadSectors 0x1
   @Entry
   @  R1 = &1 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R3 = data (pointer to data)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress64)
   @  R3 = next_data (pointer to data)
   @  R4 = unread (Int)

#  define ADFSDiscOp64_WriteSectors 0x2
   @Entry
   @  R1 = &2 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R3 -> data (data)
   @  R4 = size (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress64)
   @  R3 -> next_data (data)
   @  R4 = unwritten (Int)

#  define ADFSDiscOp64_ReadTrack 0x3
   @Entry
   @  R1 = &3 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R3 = data (pointer to data)

#  define ADFSDiscOp64_ReadId 0x3
   @Entry
   @  R1 = &3 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R3 = data (pointer to data)

#  define ADFSDiscOp64_WriteTrack 0x4
   @Entry
   @  R1 = &4 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R3 -> data (data)

#  define ADFSDiscOp64_FormatTrack 0x4
   @Entry
   @  R1 = &4 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R3 = &0
   @  R4 -> format (FileCore_TrackFormat)

#  define ADFSDiscOp64_Seek 0x5
   @Entry
   @  R1 = &5 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)

#  define ADFSDiscOp64_Restore 0x6
   @Entry
   @  R1 = &6 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)

#  define ADFSDiscOp64_StepIn 0x7
   @Entry
   @  R1 = &7 :OR: flags (Bits)

#  define ADFSDiscOp64_StepOut 0x8
   @Entry
   @  R1 = &8 :OR: flags (Bits)

#  define ADFSDiscOp64_ReadSectorsViaCache 0x9
   @Entry
   @  R1 = &9 :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)
   @  R3 = data (pointer to data)
   @  R4 = size (Int)
   @  R6 = cache_handle (Int)
   @Exit
   @  R2 = next_disc_addr (FileCore_DiscAddress64)
   @  R3 = next_data (pointer to data)
   @  R4 = unread (Int)
   @  R6 = cache_handle_out (Int)

#  define ADFSDiscOp64_Specify 0xf
   @Entry
   @  R1 = &F :OR: flags (Bits)
   @  R2 = disc_addr (FileCore_DiscAddress64)

.set XADFS_ATAPIOp,0x60255
.set ADFS_ATAPIOp,0x40255

#  define Service_IdentifyFormat 0x6b
   @Entry
   @  R0 -> format (String)
   @  R1 = &6B
   @Exit
   @  R0 -> command (String)
   @  R1 = unclaimed (Bool)
   @  R2 = disc_format_swi (Int)
   @  R3 = disc_format_handle (Int)
   @  R4 = layout_structure_swi (Int)
   @  R5 = layout_structure_handle (Int)

#  define Service_DisplayFormatHelp 0x6c
   @Entry
   @  R0 = &0
   @  R1 = &6C
   @Exit
   @  R0 -> error (OS_Error)
   @  R1 = unclaimed (Bool)

#endif
